package com.vhall.component.framework.common.utils;

import javax.annotation.Nullable;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

/**
 * 集合工具类
 *
 * @author xiaoliang.wang@vhall.com
 */
public class CollectionUtils {

    private CollectionUtils() {
        throw new IllegalStateException("Utility class");
    }

    /**
     * 判断集合是否为空
     */
    public static boolean isEmpty(@Nullable Collection<?> collection) {
        return (collection == null || collection.isEmpty());
    }

    /**
     * 判断集合是否为空
     */
    public static boolean isEmpty(@Nullable Map<?, ?> map) {
        return (map == null || map.isEmpty());
    }

    public static boolean isEmpty(byte[] array) {
        return !isNotEmpty(array);
    }

    /**
     * 判断集合是否为空
     */
    public static boolean isNotEmpty(@Nullable Collection<?> collection) {
        return (collection != null && !collection.isEmpty());
    }

    public static boolean isNotEmpty(byte[] array) {
        return null != array && array.length > 0;
    }

    /**
     * 判断集合是否为空
     */
    public static boolean isNotEmpty(@Nullable Map<?, ?> map) {
        return (map != null && !map.isEmpty());
    }

    /**
     * 集合元素重包装
     */

    public static Map collectors(@Nullable Map<?, ?> map) {
        return new HashMap<>(map);
    }

}
